package com.scedu.controller;

import com.scedu.domain.SysRole;
import com.scedu.domain.SysUser;
import com.scedu.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping("/role")
@Controller
public class RoleController {
    @Autowired
    RoleService roleService;
    @RequestMapping("/findAll")
    public String findAll(Model model){

        List<SysRole> list = roleService.findAll();
        model.addAttribute("list", list);
        return "pages/role-list";
    }

    @RequestMapping("/role-add")
    public String useradd(){
        return "pages/role-add";
    }
    @RequestMapping("/save")
    public String save(SysRole sysRole){
        roleService.save(sysRole);
        return "redirect:findAll";
    }
}
